/*
 * Created on Jun 6, 2005
 *
 */
package com.erclab.internal.xpresso.dataAccess;

import java.util.ArrayList;

import com.erclab.internal.xpresso.exceptions.DataSourceException;
import com.erclab.internal.xpresso.reports.Report;
import com.erclab.internal.xpresso.reports.ReportResultSet;

/**
 * @author Enrique Rodriguez.
 *
 */
public abstract class ApplicationDataSource {
	protected String idDataSource;
	protected String dataSourceName;
	protected String classHandler;
	protected String parameters;
	protected QueryBuilder queryBuilder;
	protected Object theDataSource;
	
	
	/**
	 * @return
	 */
	public String getClassHandler() {
		return classHandler;
	}

	/**
	 * @return
	 */
	public String getDataSourceName() {
		return dataSourceName;
	}

	/**
	 * @return
	 */
	public String getIdDataSource() {
		return idDataSource;
	}

	/**
	 * @return
	 */
	public String getParameters() {
		return parameters;
	}

	/**
	 * @return
	 */
	public Object getTheDataSource() {
		return theDataSource;
	}

	/**
	 * @param string
	 */
	public void setClassHandler(String string) {
		classHandler = string;
	}

	/**
	 * @param string
	 */
	public void setDataSourceName(String string) {
		dataSourceName = string;
	}

	/**
	 * @param string
	 */
	public void setIdDataSource(String string) {
		idDataSource = string;
	}

	/**
	 * @param string
	 */
	public void setParameters(String string) {
		parameters = string;
	}

	/**
	 * @param object
	 */
	public void setTheDataSource(Object object) {
		theDataSource = object;
	}

	public abstract void createDataSource() throws DataSourceException;
	public abstract ReportResultSet runReportQuery(Report r) throws DataSourceException;
	public abstract GenericResultSet runQuery(String query) throws DataSourceException;
	public abstract GenericResultSet runQuery(Query q)throws DataSourceException;
	public abstract void executeQuery(Query q) throws DataSourceException;
	public abstract void executeUpdate(ArrayList attributes, 
									String destinationObject, 
									String uniqueKeyName, 
									String uniqueKeyValue) throws DataSourceException;
	public abstract void executeInsert(ArrayList attributes, 
									String destinationObject, 
									String uniqueKeyName, 
									String uniqueKeyValue) throws DataSourceException;
	/**
	 * @param Storage Object associated (ie. A table in a relational DB) 
	 * @param UniqueKeyName
	 * @param UniqueKeyValue
	 */
	public abstract void executeDelete(String storageObject, 
										String uniqueKeyName, 
										String uniqueKeyValue)throws DataSourceException;


	/**
	 * @return
	 */
	public QueryBuilder getQueryBuilder() {
		return queryBuilder;
	}

	/**
	 * @param builder
	 */
	public void setQueryBuilder(QueryBuilder builder) {
		queryBuilder = builder;
	}

	/**
	 * @param string
	 * @param attributes
	 * @param table
	 * @param uniqueKeyName
	 * @param uniqueKeyValue
	 */
	public abstract void executeMultipleValueQuery(String action, 
											ArrayList attributes, 
											String table, 
											String uniqueKeyName, 
											String uniqueKeyValue)throws DataSourceException;

}
